home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / GraphicsWorkshop / Source / Converters / PCX_SCRATCH / test.m < prev   
Encoding:
Text File  |  1993-01-15  |  718 b   |  36 lines

  1. #include <stdio.h>
  2. #include <appkit/NXBitmapImageRep.h>
  3. #include <streams/streams.h>
  4. #include "pcxlib.h"
  5. #include "ImageControl.h"
  6.  
  7. void main(int argc, char *argv[])
  8. {
  9.     id                image;
  10.     NXStream        *outStream;
  11.     FILE            *outFile;
  12.     id                imageCon;
  13.     unsigned char        *data, r[256], g[256], b[256];
  14.  
  15.     image = [[NXBitmapImageRep alloc] initFromFile: argv[1]];
  16.     
  17.     outFile = fopen("out.pcx", "w");
  18.     outStream = NXOpenFile(fileno(outFile), NX_WRITEONLY);
  19.     
  20.     imageCon = [ImageControl new: image];
  21.     
  22.     [imageCon convertToPalette:     256
  23.                 andReturn:        &data
  24.                 andPalettes:        r:g:b];
  25.     
  26.     pcxwrite(outStream,
  27.             data, r, g, b,
  28.             [image pixelsWide],
  29.             [image pixelsHigh],
  30.             256);
  31.     
  32.     NXClose(outStream);
  33.     fclose(outFile);
  34.     [image free];
  35. }
  36.